//
//  UIBarButtonItem+Extension.swift
//  新浪微博
//
//  Created by WTFKL on 17/8/7.
//  Copyright © 2017年 WTF. All rights reserved.
//

import UIKit

class UIBarButtonItem_Extension: UIBarButtonItem {

}


extension UIBarButtonItem {
    
    
    /// 便利构造方法
    /// 由于 便利构造方法不提供对象实例化，我们得先实例化再进行属性赋值
    /// - Parameters:
    ///   - title: title
    ///   - style: style
    ///   - target: target
    ///   - action: action
    ///   - normalTextColor: color 默认为蓝色
    ///   - highLighttextColor: color 默认为蓝色
    ///   - isBack 默认为false
    convenience init(title : String , style : UIBarButtonItemStyle, target : Any? , action : Selector ,normalTextColor : UIColor? ,highLightTextColor : UIColor? , isBack : Bool = false){
        
        let barBtn : UIButton = UIButton().createCustomButton(title: title, imageName: nil, state: .normal, setForImageOrBgImage: .foreImage);
        
        barBtn.addTarget(target, action: action, for: .touchUpInside);
        barBtn.setTitleColor(normalTextColor, for: .normal)
        barBtn.setTitleColor(highLightTextColor, for: .highlighted);
        if isBack {
            barBtn.setImage(#imageLiteral(resourceName: "navigationButtonReturn"), for: .normal);
            barBtn.setImage(#imageLiteral(resourceName: "navigationButtonReturnClick"), for: .highlighted);
        }
        barBtn.sizeToFit();
        
        
        self.init(customView : barBtn);
        
        
        

    }
    
}
